import java.awt.Component;

import org.jbox2d.callbacks.DebugDraw;
import org.jbox2d.common.Color3f;
import org.jbox2d.common.IViewportTransform;
import org.jbox2d.common.OBBViewportTransform;
import org.jbox2d.common.Transform;
import org.jbox2d.common.Vec2;


public class DebugDraw2D extends DebugDraw {
	
	private GeometricDraw geom;

	public DebugDraw2D(Component comp) {
		super(new OBBViewportTransform());
		viewportTransform.setYFlip(true);
		
		//System.out.println(viewportTransform.getCenter());
		//viewportTransform.setExtents(250, 250);
		
		geom = new GeometricDraw(comp);
	}

	@Override
	public void drawCircle(Vec2 center, float radius, Color3f color) {
		System.out.println("Circle: " + center);
		geom.circle(center, radius, color, null);
	}

	@Override
	public void drawPoint(Vec2 position, float screenRadius, Color3f color) {
		System.out.println("Point: " + position);
		geom.point(position, screenRadius, color);
	}

	@Override
	public void drawSegment(Vec2 p1, Vec2 p2, Color3f color) {
		System.out.println("Segment: " + p1 + ", " + p2);
		geom.segment(p1, p2, color);
	}

	@Override
	public void drawSolidCircle(Vec2 center, float radius, Vec2 axis, Color3f color) {
		System.out.println("Solid circle: " + center);
		geom.circle(center, radius, color, color);
	}

	@Override
	public void drawSolidPolygon(Vec2[] vertices, int numberOfVertices, Color3f color) {
		System.out.println("Solid polygon: " + numberOfVertices);
		
		Vec2[] real = new Vec2[numberOfVertices];
		
		for(int i = 0; i < numberOfVertices; i++) {
			real[i] = vertices[i];
		}
		
		geom.polygon(real, numberOfVertices, color, color);
	}

	@Override
	public void drawString(float x, float y, String s, Color3f color) {
		geom.string(x, y, s, color);
	}

	@Override
	public void drawTransform(Transform transform) {
		geom.transform(transform);
	}
}
